// 获取背景图banner
var img = document.querySelector('.banner img');
// console.log(img)
var xhr = new XMLHttpRequest();
xhr.open("get","https://locally.uieee.com/slides");
xhr.send();
xhr.onreadystatechange = function () {
	if (xhr.readyState === 4) {
		if (xhr.status === 200) {
			var objImg = JSON.parse(xhr.responseText);
			// console.log(objImg);
			// console.log(objImg[0].image)
			img.src = objImg[0].image;

		} else{
			console.log('获取失败');
		}
	}
}
// 获取九宫格图片
var lattice = document.querySelector(".lattice");
var xhrr = new XMLHttpRequest();
xhrr.open("get","https://locally.uieee.com/categories");
xhrr.send();
xhrr.onreadystatechange = function () {
	if (xhrr.readyState === 4) {
		if (xhrr.status === 200) {
			var objLattice = JSON.parse(xhrr.responseText);
			console.log(objLattice);
			// console.log(objImg[0].image)
			for(var i = 0; i < objLattice.length;i++){
				var item = document.createElement('div');
				item.className = 'item';
				item.innerHTML = "<img alt='' src="+ objLattice[i].icon +"><span>" + objLattice[i].name + "</span>";
				lattice.appendChild(item);//
			}

		} else{
			console.log('获取失败');
		}
	}
}
// 点击更换图片
// background: url(../images/home.png) no-repeat center 8px;
//             url("../images/change2.png")
var change = document.querySelectorAll('.bottom_nav div');
// for(var i = 0;i < change.length;i++){
// 	change[i].index = i;
// 	change[i].addEventListener('click',function(){
// 		console.log(this.index)
// 		this.style.backgroundImage ='url(./images/change'+ this.index + '.png' ;
// 		console.log(this.style.background);
// 	})
// }
change[0].addEventListener('click',function(){
	location.href="./index.htm";
})
change[1].addEventListener('click',function(){
	location.href="./404.htm";
})
change[2].addEventListener('click',function(){
	location.href="./404.htm";
})

